clear all
set more off


cd "\workfiles"

****=====================================================================
****			distribution of beliefs by horizon
****=====================================================================
use step001_QJE_2, clear

keep if it12_all>=-3

sum infl if time==211
local inf0=r(mean)
twoway (kdensity it12  [aw=peso] if time==211 & it12>-3, bw(0.25) lpattern(dash) lcolor(red) ) ///
	   (kdensity it12n  [aw=peso] if time==211, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel A: 2012Q4") ///
	graphregion(color(white)) bgcolor(white) ///
	xlabel(-3(1)10) ///
	ylabel(0(0.2)1) ///
	name(fig210, replace) ///
	xline(`inf0', lcolor(blue)) ///
	text(0.87 1  "treatment", color(blue))
	
sum infl if time==215
local inf0=r(mean)	
twoway (kdensity it12  [aw=peso] if time==215, bw(0.25) lpattern(dash) lcolor(red) ) ///
	   (kdensity it12n  [aw=peso] if time==215, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel B: 2013Q4") ///
	graphregion(color(white)) bgcolor(white)  ///
	xlabel(-3(1)10) ///
	ylabel(0(0.2)1) ///
	name(fig212, replace) ///
	xline(`inf0', lcolor(blue)) 

sum infl if time==219
local inf0=r(mean)
twoway (kdensity it12  [aw=peso] if time==219, bw(0.25) lpattern(dash) lcolor(red) ) ///
	   (kdensity it12n  [aw=peso] if time==219, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel C: 2014Q4") ///
	graphregion(color(white)) bgcolor(white)  ///
	xlabel(-3(1)10)  ///
	ylabel(0(0.2)1) ///	
	name(fig216, replace) ///
	xline(`inf0', lcolor(blue))

sum infl if time==223
local inf0=r(mean)	
twoway (kdensity it12  [aw=peso] if time==223, bw(0.25) lpattern(dash) lcolor(red) ) ///
	(kdensity it12n  [aw=peso] if time==223, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel D: 2015Q4") ///
	graphregion(color(white)) bgcolor(white)  ///
	xlabel(-3(1)10)  ///
	ylabel(0(0.2)1) ///
	name(fig220, replace) ///
	xline(`inf0', lcolor(blue))
	
sum infl if time==227
local inf0=r(mean)	
twoway (kdensity it12  [aw=peso] if time==227, bw(0.25) lpattern(dash) lcolor(red) ) ///
		(kdensity it12n  [aw=peso] if time==227, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel E: 2016Q4") ///
	graphregion(color(white)) bgcolor(white) ///
	xlabel(-3(1)10)  ///
	ylabel(0(0.2)1) ///
	name(fig224, replace)  ///
	xline(`inf0', lcolor(blue))

sum infl if time==231
local inf0=r(mean)		
twoway (kdensity it12  [aw=peso] if time==231, bw(0.25) lpattern(dash) lcolor(red) ) ///
		(kdensity it12n  [aw=peso] if time==231, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel F: 2017Q4") ///
	graphregion(color(white)) bgcolor(white) ///
	xlabel(-3(1)10)  ///
	ylabel(0(0.2)1) ///	
	name(fig228, replace) ///
	xline(`inf0', lcolor(blue)) 
	

sum infl if time==235
local inf0=r(mean)		
twoway (kdensity it12  [aw=peso] if time==235, bw(0.25) lpattern(dash) lcolor(red) ) ///
		(kdensity it12n  [aw=peso] if time==235, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel G: 2018Q4") ///
	graphregion(color(white)) bgcolor(white) ///
	xlabel(-3(1)10)  ///
	ylabel(0(0.2)1) ///	
	name(fig232, replace) ///
	xline(`inf0', lcolor(blue))	
	
sum infl if time==236
local inf0=r(mean)		
twoway (kdensity it12  [aw=peso] if time==236, bw(0.25) lpattern(dash) lcolor(red) ) ///
		(kdensity it12n  [aw=peso] if time==236, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///
	, legend(off) ///
	xtitle("expected inflation, 1-year ahead") ///
	ytitle("density") ///
	title("Panel H: 2019Q1") ///
	graphregion(color(white)) bgcolor(white) ///
	xlabel(-3(1)10)  ///
	ylabel(0(0.2)1) ///	
	name(fig236, replace) ///
	xline(`inf0', lcolor(blue))	
	
	
*=======================================================================		
*		legend panel
*=======================================================================

twoway ///
		(kdensity it12  [aw=peso] if time==300, bw(0.25) lpattern(dash) lcolor(red) )  ///
		(kdensity it12n  [aw=peso] if time==300, bw(0.25) lpattern(solid) lcolor(black) lwidth(thick)) ///			
		, ///
		legend(order(1 2 ) label(1 "treated") label(2 "control") rows(2) ///
					ring(0) position(0) col(1)) ///
		subtitle("") ///
		ylabel(none) yscale(off) ///
		xlabel(none) xscale(off) ///
		ytitle("") xtitle("") ///
		graphregion(color(white) fcolor(white)) ///
		plotregion(color(white) fcolor(white)) ///
		name(figure_legend, replace)
		
		
graph combine fig210 fig212 fig216 fig220 fig224 fig228 fig232 figure_legend, ///
	rows(2) imargin(tiny) ///
	graphregion(color(white)) ///
	xsize(16) ysize(8) ///
	name(comb2, replace)

